<template>
	<view class="gray">
		<view class="home-user" @click="handleUserProfileButton()">
			<view class="layout">				
				<view class="header-user-icon">
					<image src="/static/icon/icon-user.png"></image>
				</view>
				<view class="home-user-login" v-if="customerData == false" @click="handleLoginButton()">
					点击登录
				</view>
				<view v-if="customerData != false" class="header-user-note">
					<view class="header-user-note-name">{{customerData.fullname}}</view>
					<view class="header-user-note-code">UID：{{customerData.customerCode}}</view>
				</view>
				<view v-if="customerData != false" class="header-user-button">
					<image src="/static/icon/icon-next.png"></image>
				</view>
			</view>
		</view>
		<view class="scantron" @click="handleExamineButton()">
			<view class="scantron-header">
				<view>答题卡</view>
				<view class="layout">
					<view>未答</view>
					<view>答对</view>
					<view>答错</view>
				</view>				
			</view>
			<view class="scantron-box">
				<view class="scantron-box-card">1</view>
			</view>
		</view>
		<view class="exam">
			<view class="exam-header">
				<view>考试情况</view>
				<view class="layout">
					<view>未答</view>
					<view>答对</view>
					<view>答错</view>
				</view>				
			</view>
			<view class="exam-box">
				<view class="scantron-box-card">1</view>
			</view>
		</view>
		<view class="home-block">
			<view class="home-block-box">
				<view class="layout">
					<view class="home-block-box-item" @click="handleOrderButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-order-list.png"></image>
						</view>
						<view class="home-block-box-item-text">全部订单</view>
					</view>
					<view class="home-block-box-item" @click="handleOrderButton(1)">			
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-order-wait.png"></image>
						</view>
						<view class="home-block-box-item-text">待付款</view>
					</view>
					<view class="home-block-box-item" @click="handleOrderButton(2)">		
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-order-delivery.png"></image>
						</view>
						<view class="home-block-box-item-text">待收货</view>
					</view>
					<view class="home-block-box-item" @click="handleOrderButton(3)">		
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-order-finish.png"></image>
						</view>
						<view class="home-block-box-item-text">已完成</view>
					</view>
				</view>
			</view>
		</view>
		<view class="home-block">
			<view class="home-block-box">
				<view class="layout">
					<view class="home-block-box-item" @click="handleFundHomeButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-fund.png"></image>
						</view>
						<view class="home-block-box-item-text">全部资产</view>
					</view>
					<view class="home-block-box-item" @click="handleFundHomeButton(1)">			
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-order-wait.png"></image>
						</view>
						<view class="home-block-box-item-text">待付款</view>
					</view>
					<view class="home-block-box-item" @click="handleFundHomeButton(2)">		
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-expire.png"></image>
						</view>
						<view class="home-block-box-item-text">已到期</view>
					</view>
					<view class="home-block-box-item" @click="handleFundHomeButton(3)">		
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-order-finish.png"></image>
						</view>
						<view class="home-block-box-item-text">赎回中</view>
					</view>
				</view>
			</view>
		</view>
		<view class="home-block">
			<view class="home-block-box">
				<view class="layout">
					<view class="home-block-box-item" @click="handleCollectionButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-collection.png"></image>
						</view>
						<view class="home-block-box-item-text">收藏</view>
					</view>		
					<view class="home-block-box-item" @click="handleFootmarkButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-footmark.png"></image>
						</view>
						<view class="home-block-box-item-text">浏览记录</view>
					</view>
					<view class="home-block-box-item" @click="handleCouponButton()">	
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-coupon.png"></image>
						</view>
						<view class="home-block-box-item-text">优惠卷</view>
					</view>
					<view class="home-block-box-item" @click="handleProfileButton()">			
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-setting.png"></image>
						</view>
						<view class="home-block-box-item-text">设置</view>
					</view>
				</view>
			</view>
		</view>
		<view class="home-block">
			<view class="home-block-header">其他功能</view>
			<view class="home-block-box">
				<view class="layout flex-wrap">
					<view class="home-block-box-item">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-service.png"></image>
						</view>
						<view class="home-block-box-item-text">我的客服</view>
					</view>
					<view class="home-block-box-item">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-protocle.png"></image>
						</view>
						<view class="home-block-box-item-text">服务协议</view>
					</view>
					<view class="home-block-box-item">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-privacy.png"></image>
						</view>
						<view class="home-block-box-item-text">隐私政策</view>
					</view>
					<view class="home-block-box-item" @click="handleFeedbackButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-feedback.png"></image>
						</view>
						<view class="home-block-box-item-text">意见反馈</view>
					</view>
					
					
					<view class="home-block-box-item">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-help.png"></image>
						</view>
						<view class="home-block-box-item-text">帮助中心</view>
					</view>
					
					<view class="home-block-box-item">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-tousu.png"></image>
						</view>
						<view class="home-block-box-item-text">投诉建议</view>
					</view>
					
					<view class="home-block-box-item" @click="handleShoppingButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-address.png"></image>
						</view>
						<view class="home-block-box-item-text">收货地址</view>
					</view>
					
					<view class="home-block-box-item">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-service.png"></image>
						</view>
						<view class="home-block-box-item-text">生活缴费</view>
					</view>
					
					
					<view class="home-block-box-item" @click="handleDistributionButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/distribution/icon-agent.png"></image>
						</view>
						<view class="home-block-box-item-text">城市合伙人</view>
					</view>
					<view class="home-block-box-item" @click="handleScancodeButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-scan.png"></image>
						</view>
						<view class="home-block-box-item-text">扫一扫</view>
					</view>
					<view class="home-block-box-item" @click="handleFundButton()">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-service.png"></image>
						</view>
						<view class="home-block-box-item-text">基金</view>
					</view>
					<view class="home-block-box-item">
						<view class="home-block-box-item-icon">
							<image src="/static/icon/icon-service.png"></image>
						</view>
						<view class="home-block-box-item-text">工具大全</view>
					</view>
				</view>
			</view>
		</view>
		<view class="copyright">
			<view class="copyright-block">
					<view>客服电话工作时间</view>
			</view>
			<view class="copyright-block">
					<view>老年人直连热线工作时间</view>
			</view>
			<view class="copyright-block">
				算法举报与未成年人举报渠道同上
			</view>
			<view class="copyright-block">
				人力资源服务许可证
				营业执照
				朝阳区人社局监督电话
			</view>
			<view class="copyright-block">
				京ICP备14013441号-23A
				京ICP证150923号
			</view>
			<view class="copyright-block">
				算法备案信息
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				customerData:false
			}
		},
		onShow() {
			let _this = this;
			_this.customerData = this.$cache.get('customer');
			_this.$authentication.getUserInfo().then(res=>{
				if(res.code == 200){
					_this.customerData = res.data;
					_this.$cache.put('customer',res.data,0)
				}else{
					
				}
			});
			_this.customerData = false
			console.log(typeof(this.customerData),this.customerData)
		},
		methods: {
			handleScancodeButton:function(){
				let _this = this;
				let fromText = "aGVsbG8gd29ya2Q9d3d3LmJhaWR1LmNvbQ=="
				console.log("解密二维码",this.$helper.base64Decode(fromText))
				console.log(atob(fromText))
				uni.scanCode({
					success(res) {
						console.log(res.scanType,res.result)
						let fromData = res.result.split("#")
						console.log(fromData)
						console.log(_this.$helper.base64Decode(formData))
						uni.showModal({
							confirmText:res.result
						})
					},
					fail(res) {
						console.log("扫码失败",res)
					},
					complete(res) {
						console.log("扫一扫",res)
					}
				})
			},
			handleFootmarkButton:function(){
				uni.navigateTo({
					url:"/pages/home/footmark/footmark"
				})
			},
			handleDistributionButton:function(){
				uni.navigateTo({
					url:"/pages/distribution/main/main"
				})
			},
			handleExamineButton:function(){
				uni.navigateTo({
					url:"/pages/examine/main/main"
				})
			},
			handleOrderButton:function(orderStatus){
				let toUrl = "/pages/home/order/order"
				if(orderStatus != undefined){
					orderStatus = parseInt(orderStatus)
					if(!isNaN(orderStatus)){
						toUrl += "?orderStatus="+orderStatus
					}
				}
				uni.navigateTo({
					url:toUrl
				})
			},
			handleFundHomeButton:function(){
				uni.navigateTo({
					url:"/pages/home/fund/fund"
				})
			},
			handleLoginButton:function(){
				uni.navigateTo({
					url:"/pages/authentication/login/login"
				})
			},
			handleUserProfileButton:function(){
				uni.navigateTo({
					url:"/pages/home/profile/profile"
				})
			},
			handleFundButton:function(){
				uni.redirectTo({
					url:"/pages/fund/main/main"
				})
			},
			handleCouponButton:function(){
				uni.navigateTo({
					url:"/pages/home/coupon/coupon"
				})
			},
			handleCollectionButton:function(){
				uni.navigateTo({
					url:"/pages/home/collection/collection"
				})
			},
			handleFeedbackButton:function(){
				uni.navigateTo({
					url:"/pages/about/feedback/feedback"
				})
			},
			handleShoppingButton:function(){
				uni.navigateTo({
					url:"/pages/transaction/address/address"
				})
			}
		}
	}
</script>

<style>
.home-user { background:#fff; }
.home-user-login { font-size: 32px; font-weight: 900; padding-top: 70rpx; text-align: left; }
.home-user-login { width:530rpx; }
.header-user-icon { width:150rpx; height:150rpx; padding:50rpx 20rpx; padding-left: 25rpx; }
.header-user-icon image { width: 100%; height:100%; border-radius:20rpx; }
.header-user-note { width: 500rpx; padding:50rpx 0; }
.header-user-note-name { padding-bottom:25rpx; font-size:24px; font-weight:bold; }
.header-user-button { width: 30rpx; padding-top: 100rpx; height: 30rpx;}
.header-user-button image { width: 100%; height: 100%; }

.home-block { background: #fff; width: 670rpx; margin: 0 25rpx; border-radius: 20rpx; padding: 15rpx; margin-top: 30rpx;}
.home-block-header { padding: 15rpx; }
.home-block-box {}
.home-block-box-item { width: 165rpx; height: 100rpx; margin-bottom: 20rpx; text-align: center; padding-top: 10rpx; }
.home-block-box-item-icon { width: 50rpx; height: 50rpx; margin: 0 auto;}
.home-block-box-item-text { padding-top: 10rpx;}

.exam { background: #fff; width: 670rpx; margin: 0 25rpx; border-radius: 20rpx; padding: 15rpx; margin-top: 30rpx;}
.scantron { background: #fff; width: 670rpx; margin: 0 25rpx; border-radius: 20rpx; padding: 15rpx; margin-top: 30rpx;}

.copyright { text-align: center; padding: 25rpx 0; color: #999; font-size: 14px; }
.copyright-block { padding: 10rpx 0;}
</style>
